﻿using System.Drawing;

namespace CloudShot.Utils.Drawings
{
  public static class ImageExtensions
  {
    public static Image ReplaceColor(this Image image, Color oldColor, Color newColor)
    {
      var result = new Bitmap(image);

      for (int x = 0; x < result.Width; x++)
      {
        for (int y = 0; y < result.Height; y++)
        {
          Color color = result.GetPixel(x, y);

          if (color.ToArgb() == oldColor.ToArgb())
            result.SetPixel(x, y, newColor);
        }
      }

      return result;
    }
  }
}